package controllers;

import java.util.Vector;

import javax.swing.table.AbstractTableModel;

import models.*;

public class MyTurnosTableModel extends AbstractTableModel {
	
	private String [] columnNames = {"Fecha", "Hora"};
    private Vector<Turno> turnos;
    
	public MyTurnosTableModel (Vector<Turno> turnos) {
		this.turnos = turnos;
	}

	@Override
	public int getColumnCount() {
		 return columnNames.length;
		
	}
	@Override
    public String getColumnName(int col){
		return columnNames[col];
	}

	@Override
	public int getRowCount() {
		 return this.turnos.size();

	}

	public Turno getTurnoAt(int row) {
		return turnos.get(row);
	}
	
	public void removeTurnoAt(int row){
           turnos.remove(row);
           fireTableDataChanged();
   }

	@Override
    public Object getValueAt(int row, int col) {
		Turno turno = turnos.get(row);
        switch (col) {
        case 0:
        		return turno.getFecha().toString();
        case 1:
    		return turno.getHora();
        default:
                return null;
        }
	}

	public void removeAll() {
		turnos.removeAllElements();
		  fireTableDataChanged();
		
	}

}
